{% extends "menu.html" %}
{% block content %}

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">



            </div>
            <div class="clearfix"></div>
            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>新增主机</h2>

                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post">
                        {% csrf_token %}
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 主机名<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="host_name" placeholder="最终名称为项目别名+主机名">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 主机ip<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="host_ip" ><br>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">系统版本<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="host_version" placeholder="c7" ><br>
                            u----表示ubuntu系统<br>
                            c----表示centos系统,比如c6表示centos6 以下的版本，c7 表示centos7版本
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 登录方式<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <p style="margin-top: 6px">密码登录：<input type="radio" name="login_type" value="1" checked> key登录： <input type="radio" name="login_type" value="2"></p>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 所属项目<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select style="width: 60%;height:auto" size="10" name="host_project">
                              {% for project in projects_list %}
                              <option value="{{ project.id }}">{{ project.p_name }}</option>
                              {% endfor %}
                          </select>
                        </div>
                      </div>

                        <div class="form-group">
                        <label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12"></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <span>{{ result }}</span>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                          <button class="btn btn-primary" type="button">Cancel</button>
						  <button class="btn btn-primary" type="reset">Reset</button>
                          <button type="submit" class="btn btn-success">Submit</button>
                        </div>
                      </div>

                    </form>
                  </div>
                </div>
                  <div class="x_panel">
                  <div class="x_title">
                    <h2>主机列表 </h2>

                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <table class="sui-table table-bordered">
                          <thead>
                            <tr>
                                <th>ID</th>
                                <th>host_name</th>
                                <th>host_ip</th>
                                <th>login_type</th>
                                <th>project</th>
                                <th>管理 </th>


                            </tr>
                          </thead>
                          <tbody>
                          <style type="text/css">
                             tr:hover{
                                 background-color: #FFFFE0;
                             }
                          </style>
                          {% for i in hosts_list %}
                            <tr>

                                <td>{{ i.id}}</td>
                                <td>{{ i.host_name }}</td>
                                <td>{{ i.host_ip }}</td>
                            {% if i.login_type == "1" %}
                                <td>密码登录</td>
                            {% else %}
                            <td>key登录</td>
                            {% endif %}
                                <td>{{ i.host_project__p_name }}</td>
                                {% if i.init_status == "1"  %}
                                <td><a href="/hosts/del/?id={{ i.id}}" class="label label-danger" >删除</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/hosts/init/?id={{ i.id}}" class="label label-info" >系统初始化</a></td>
                                {% else %}
                                          <td><a href="/hosts/del/?id={{ i.id}}" class="label label-danger" >删除</a>&nbsp;&nbsp;</td>

                                {% endif %}
                            </tr>
                        {% endfor %}
                          </tbody>
                      </table>
                  </div>
                </div>
              </div>
            </div>


          </div>
        </div>
{% endblock %}